home *** CD-ROM | disk | FTP | other *** search
- {-----------------------------------------------------------------
-
- This is the TML Pascal source for an FKEY that launches
- another application from within an application.
-
- LaunchKey version 1.20
- copyright Oct/86, Greg King [72407,175]
-
- -----------------------------------------------------------------}
- program myfkey;
-
- {$H 'PAS$FKEYHeader'} { we want the special FKEY header }
- {$C 'FKEY' 5 'LaunchKey'} { create an FKEY resource with an ID = 5}
- {$T 'FKEY' 'QD15'} { make an FKEY Installer document }
- {$O-}
- {$R-}
- uses macintf;
- PROCEDURE FKEY; { must be called FKEY }
-
- { see Macintosh Tech Note 52 about the following types }
-
- TYPE
- LaunchStruct = RECORD
- pfName : StringPtr;
- param : integer;
- END; {LaunchStruct}
- pLaunchStruct = ^LaunchStruct;
- VAR
- mylaunch : LaunchStruct;
- plaunch : pLaunchStruct;
- name : StringPtr;
- r : rect; { rectangle for my copyright window }
- reply : SFReply;
- mywindow, savewindow : WindowPtr;
- mytype : SFTypeList;
- pt : Point;
- err : OSErr;
- mytext : Str255;
-
- { see Macintosh Tech Note 52 about the following procedure }
-
- PROCEDURE Launch (p : pLaunchStruct);
- INLINE
- $205F, $A9F2;
-
- BEGIN
-
- { save the current window context and put up my copyright window }
-
- GetPort(savewindow);
- SetRect(r, 150, 40, 350, 80);
- mytext := 'x';
- mywindow := NewWindow(NIL, r, mytext, TRUE, 1, WindowPtr(-1), False, LongInt(0));
- SetPort(mywindow);
- HideCursor;
- TextSize(9);
- MoveTo(10, 10);
- mytext := 'LaunchKey 1.20';
- DrawText(Pointer(Ord(@mytext) + 1), 0, 14);
- MoveTo(10, 20);
- mytext := '©Greg King - Oct 10/86';
- DrawText(Pointer(Ord(@mytext) + 1), 0, 22);
- MoveTo(10, 30);
- mytext := 'Open an application to launch';
- DrawText(Pointer(Ord(@mytext) + 1), 0, 29);
- ShowCursor;
-
- { call SFGetFile and look for applications }
-
- mytype[0] := 'APPL';
- SetPt(pt, 75, 100);
- SFGetFile(pt, '', ProcPtr(NIL), 1, mytype, ProcPtr(NIL), reply);
-
- { restore original window context }
-
- DisposeWindow(mywindow);
- SetPort(savewindow);
- IF reply.good = TRUE THEN { if cancel wasn't pressed }
- BEGIN
-
- { set new volume }
-
- name := @reply.fName;
- err := SetVol(name, reply.vRefNum);
- IF err = noErr THEN { if no errors then launch }
- BEGIN
-
- { see Tech note 52 }
-
- pLaunch := @mylaunch;
- mylaunch.pfName := name;
- mylaunch.param := 0;
- Launch(plaunch);
- END
- ELSE
- SysBeep(3); { if problems, beep and return to the user }
- END;
- END; {FKEY}
-
- begin {we cant have anything here!}
- end.